/*
 *   Copyright (C) 2019 All rights reserved.
 *
 *   FileName      ：util.h
 *   Author        ：yuefei.Chen
 *   Email         ：yfei777@outlook.com
 *   Date          ：2019年03月21日
 *   Description   ：
 */
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/sysinfo.h>
#include <unistd.h>
/*
 * 登录信息结构体，记录登录用户名与登录时间，
 */
struct logininfo {
				char userName[1024];
				char loginTime[64];
};

struct cpu_occupy {
				char name[20];
				unsigned int user;
				unsigned int nice;
				unsigned int system;
				unsigned int idle;
}; 


struct logininfo *read_login_info(void);

void write_login_info(char *userName);

void get_current_time(char time_str[], int n);

void sys_info(long *uptime,long* totalram);

void random_key(char str[], int num);

void get_cpu_occupy(struct cpu_occupy* cpu_opy);

void cal_cpu_occupy(double *rate);

void cal_mem_occupy(double *rate);

void cal_net_info(unsigned long *rx,unsigned long *tx);
